<style>
	#fx_weixin{
		display: none;
		width:100px;
		height: 100px;
	position: absolute;
		z-index:9999;
		right: 10%;
		bottom: 10%;}
	#fx_pengyouquan{
		display: none;
		width:100px;
		height: 100px;
		position: relative;
		z-index:9999;
		bottom: 42px;
		right: -12%;
	}

	.mui-icon{
		line-height: 0;
	}
	.like .ulike {
		float: left;
		width: 48%;
		overflow: hidden;
		text-align: center;
		margin-bottom: 10px;
	}
	.like img {
		width: 80%;
		height: 158.97px;
	}


</style>
<include file="public:top" />
	<body>

		<div class="wrap">
		<div class="detail">


			<if condition="$item.isq eq 1">
				<div class="pic">
					<img src="{$item.pic_url}_480x480">
					<a href="javascript:;" class="back mui-action-back"><i class="mui-icon mui-icon-arrowleft" style="line-height: inherit;"></i></a>
				</div>
			<else/>
				<div class="pic" style="height:360px;">
					<img style="max-width: 100%;max-height: 100%" src="{$item.pic_url}">
					<a href="javascript:;" class="back mui-action-back"><i class="mui-icon mui-icon-arrowleft" style="line-height: inherit;"></i></a>
					<img src="__STATIC__/images/fenxiang.png" onclick="fenxiang()" style="position: absolute;right: 10px;top: 10px;width: 40px;height: 40px; display: none" id="fenxiang" alt="分享">

				</div>
			</if>
			<div class="tit">
				<p class="mui-ellipsis-2">
				<if condition="$item['shop_type'] eq 'B'">
				<img src="__STATIC__/tqkwap/images/tmall.png">
				</if>
				<if condition="$item['shop_type'] eq 'C'">
				<img src="__STATIC__/tqkwap/images/taobao.png">
				</if>	
					{$item.title}</p>
			</div>
			<if condition="$item.isq eq 1">
				<div class="price flexbox mui-clearfix">
					<div class="txt mui-pull-left flex">
						<h4 class="c-main">券后价：￥<span>{$item.coupon_price}</span><em>（包邮）</em></h4>
						<p><if condition="$item['shop_type'] eq 'B'">天猫</if><if condition="$item['shop_type'] eq 'C'">淘宝</if>在售:￥{$item.price}    月销 {$item.volume} 件</p>
					</div>
					<div class="tag tag-violet mui-pull-right">
						<p>RMB</p>
						<h4>{$item.quan}元</h4>
						<p>领券立省</p>
					</div>
				</div>
				<div class="report mui-clearfix">
					<ul>
						<li><a href="/?g=m&m=baoming&a=index"><i class="iconfont icon-jia"></i>卖家报名</a></li>
						<li><a href="/?g=m&m=baoming&a=jubao&num_iid={$item.num_iid}"><i class="iconfont icon-jubao"></i>举报此商品</a></li>
					</ul>
				</div>
				<else/>
				<div class="price flexbox mui-clearfix">
					<div class="txt mui-pull-left flex">
						<h4 class="c-main"><if condition="$item.price eq 0"> 暂无报价，请联系客服<else/> 预估价:￥{$item.price}</if></h4>
						<p>已经被 {$item.hits}人查看</p>
					</div>
				</div>
				<div class="report mui-clearfix">
					<ul>
						<li><a href="/?g=m&m=baoming&a=index&type=company&id={$item.id}"><i class="iconfont icon-jia"></i>对此商品感兴趣</a></li>
						<li><a href="/?g=m&m=baoming&a=index&id={$item.id}&&type=company&&channel=xy"><i class="iconfont icon-jia"></i>您有其他需求?</a></li>
					</ul>
				</div>
			</if>

		</div>
		<input type="hidden" id="Pid" value="{$item.id}" />
        <input type="hidden" id="up_time" value="{$item.up_time}" />
		<if condition="$item.isq eq 1">

			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-collapse">
					<a href="javascript:;" class="mui-navigate-right product-info" data-itemid="{$item.num_iid}">
						商品图文详情 <span class="mui-badge mui-badge-primary mui-badge-inverted">(点击展开)</span>
					</a>
					<div class="mui-collapse-content">

					</div>
				</li>
			</ul>
			<div class="like">
				<div class="mui-text-center mui-content-padded">
					<i class="iconfont icon-heart c-main"></i>猜你喜欢
				</div>
				<ul class="mui-clearfix">
					<volist name="orlike" id="val">
						<li class="ulike">
							<a href="{:U('detail/index',array('id'=>$val['id']))}{$trackurl}">
								<img src="{$val.pic_url}_300x300"/>
								<p class="mui-ellipsis">{$val.title}</p>
								<span class="c-main">券后价：￥{$val.coupon_price}</span>
							</a>
						</li>
					</volist>

				</ul>
			</div>
		</div>
		<nav class="mui-bar mui-bar-tab mui-row buy-nav">
			<a href="{:C('yh_headerm_html')}" class="mui-col-xs-2 icon"><i class="iconfont icon-home"></i><span>首页</span></a>
			<a href="javascript:;" class="mui-col-xs-2 icon" id="kefu"><i class="iconfont icon-tel"></i><span>客服</span></a>

			<if condition="$act eq 'yes'">
				<a  href="/index.php?g=m&m=out&quanurl={:base64_encode($item['quanurl'])}"  class="mui-col-xs-4 browser" >领券下单</a>
				<elseif condition="$item['que'] eq 1 || $item['tk'] eq 0"/>
				<a href="/index.php?g=m&m=out&id={$item.id}" class="mui-col-xs-4 browser" > 领券下单</a>
				<else/>
				<a id="coupon" href="javascript:;"  class="mui-col-xs-4 browser" >领券下单</a>

			</if>
			<a href="javascript:;"
			<if condition="$item['que'] eq 1 || $item['tk'] eq 0">
				class="mui-col-xs-4 taobao" id="kouling"
				<else/>
				class="mui-col-xs-4 taobao"	id="couponkouling"
			</if>
			>用淘口令领券</a>
		</nav>

		<div class="modal-dialog mui-text-center" id="modal">
			<div class="modal-hd">点击二维码放大后长按关注<a href="javascript: void(0)" class="close">×</a></div>
			<img src="{:C('yh_site_background')}" alt=""/>
			<span>客服微信</span>
		</div>

		<div class="modal-dialog mui-text-center" id="amoybuy">
			<div class="modal-hd">淘口令购买<a href="javascript: void(0)" class="close">×</a></div>
			<div class="fq-goods-border">
				<div class="fq-explain">长按框内 &gt; 拷贝</div>
				<div class="copy_key" id="copy_key_ios">复制这条信息{$item.quankouling}打开【手机淘宝】即可领取优惠券购买！</div>
				<textarea id="copy_key_android">复制这条信息{$item.quankouling}打开【手机淘宝】即可领取优惠券购买！</textarea>
				<button class="copy" data-clipboard-action="copy" data-clipboard-text="复制这条信息{$item.quankouling}打开【手机淘宝】即可领取优惠券购买！" >一键复制</button>
			</div>
			<div class="fq-instructions">
				<span>
					<span>温馨提示：</span>
					手机无【手机淘宝】者，可选择浏览器购买方式哦~
				</span>
			</div>
		</div>
		<else/>
			<ul class="mui-table-view">
				<li class="mui-table-view-cell mui-collapse">
					<a href="javascript:;" class="mui-navigate-right product-info" data-itemid="{$item.num_iid}">
						商品图文详情 <span class="mui-badge mui-badge-primary mui-badge-inverted">(点击展开)</span>
					</a>
					<div class="mui-collapse-content">
						{$item.content}
					</div>
				</li>
			</ul>
			<empty name="orlike">

			<else />
			<div class="like">
				<div class="mui-text-center mui-content-padded">
					<i class="iconfont icon-heart c-main"></i>猜你喜欢
				</div>
				<ul class="mui-clearfix">
					<volist name="orlike" id="val">
						<li class="ulike">
							<a href="{:U('detail/index',array('id'=>$val['id']))}{$trackurl}">
								<img src="{$val.pic_url}"/>
								<p class="mui-ellipsis">{$val.title}</p>
								<span class="c-main"><if condition="$val.price eq 0"> 暂无报价，请联系客服<else/> 预估价:￥{$val.price}</if></span>
							</a>
						</li>
					</volist>

				</ul>
			</div>
			</empty>
		</div>
		<nav class="mui-bar mui-bar-tab mui-row buy-nav">
			<a href="{:C('yh_headerm_html')}" class="mui-col-xs-4 browser" style="width: 50%"><i class="iconfont icon-home"></i><span>首页</span></a>
			<a href="javascript:;" class="mui-col-xs-4 taobao" style="width: 50%" id="kefu"><i class="iconfont icon-tel"></i><span>客服</span></a>


		</nav>
		<div class="modal-dialog mui-text-center" id="modal">
			<div class="modal-hd">点击二维码放大后长按关注<a href="javascript: void(0)" class="close">×</a></div>
			<img src="{:C('yh_site_background')}" alt=""/>
			<span>客服微信</span>
		</div>
		</if>
		<span style="display: none" id="channel">{$channel}</span>
		<span style="display: none" id="is_address">{$is_address}</span>

<script>
		
mui.init({
		swipeBack: false,
	});
	
	mui('body').on('tap','a:not(#offCanvasBtn)',function(){
		window.location.href=this.href;
	});
			var clipboard = new Clipboard('.copy');
			 clipboard.on('success', function(e) {
	         console.info('Action:', e.action);
             console.info('Text:', e.text);
             console.info('Trigger:', e.trigger);
             e.clearSelection();
			});
			$('.copy').on('tap',function(){
			  layer.msg('复制成功', {icon: 1,time:2000});	
			})
			 
			mui('body').on('tap','a',function(){
				window.location.href=this.href;
			});
			$("#kefu").on("tap",function(){
				layer.open({
					type:1,
					content:$("#modal"),
					skin:'modal',
					title:false,
					scrollbar:false,
					success:function(layero, index){
						$(".close").on("tap",function(){
							layer.close(index)
						})
					},
					shade:0.5,
					shadeClose:true,
				})
			})
			$("#kouling").on("tap",function(){
				layer.open({
					type:1,
					content:$("#amoybuy"),
					skin:'amoybuy',
					title:false,
					scrollbar:false,
					success:function(layero, index){
						$(".close").on("tap",function(){
							layer.close(index)
						})
					},
					shade:0.5,
					shadeClose:true,
					area:"80%"
				})
			})
	$('mui-action-back').on('tap',function(){
	window.history.go(-1);
	})
	
			function back() {
				var last_page_url = (document.referrer);
				if (last_page_url) {
					window.history.back(-1)
				} else {
					window.location.href = '/'
				}
			}

<if condition="$item['tk'] eq 1 && $item['que'] eq 0">
$("#coupon,#couponkouling").on("tap",function(){
var runcount = 0;
layer.msg('优惠券生成中，请稍等！', {
  icon: 16
  ,shade: 0.01,
  time:10000
});	
autoplay = setInterval(function(){
$.ajax({ 
        url: "/index.php?g=m&m=min&a=checkque",  
        type:'get',
        dataType: "json",
        timeout :5000,
        data: { id: {$item.num_iid}, uptime: {:time()} },
        async: true,  
        success: function(data){
        if(data.status=='ok'){
		layer.closeAll('loading');
		clearInterval(autoplay);
	  layer.msg('生成成功，现在可以领券下单啦！', {icon: 1,time:2000});
	   setTimeout(function(){
	   window.location.reload();
	   },2000);
		}
       if(data.status=='no'){
       	runcount=runcount+1
       if(runcount>0){
       layer.closeAll('loading');
       clearInterval(autoplay);
       layer.msg('生成成功，现在可以领券下单啦！', {icon: 1,time:2000});
	   setTimeout(function(){
	   window.location.reload();
	   },2000);
       }
       }

        }  
});	
},3000);

});
</if>

$(".product-info").on("tap",function(){
$.ajax({ 
        url: "{:U('detail/productinfo',array('numiid'=>$item['num_iid']))}",  
        type:'get',
        dataType: "json",
        timeout :5000,
        async: true,  
        success: function(data){
        if(data.status=='ok'){
        	$('.mui-collapse-content').html(data.content);
        }
        }
     });
        	
});
jQuery(function($){
    if (isWeiXin()) {
        fenxiangWeiXin();
    }

})

	function fenxiangWeiXin() {
        var url = location.href.split('#')[0];
        var urls = location.href.split('#')[0]+'?channel=wx';
        $.ajax({
            url: "{:U('detail/getSignature')}",
            data:{ url : url },
            type:'post',
            dataType: "json",
            timeout :5000,
            async: true,
            success: function(data) {
                if (data.status == 'ok') {
                    wx.config({
                        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                        appId: data.appId, // 必填，公众号的唯一标识
                        timestamp: data.timestamp, // 必填，生成签名的时间戳
                        nonceStr: data.noncestr, // 必填，生成签名的随机串
                        signature: data.signature,// 必填，签名
                        jsApiList: [
                            'checkJsApi',
                            'updateAppMessageShareData',
                            'updateTimelineShareData',
                            'onMenuShareAppMessage',  //旧的接口，即将废弃
                            'onMenuShareTimeline', //旧的接口，即将废弃
							'getLocation'
                        ]// 必填，需要使用的JS接口列表

                    });
                    wx.error(function (res) {
                        // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。

                    });
                     wxReady(urls);
                    getWxAddress();
                } else {
                    layer.msg(data.msg,{icon: 2,time:2000});
                }
            }
        });
    }

    function wxReady(url) {
        wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
            wx.onMenuShareAppMessage({
                title: '{$item.title}', // 分享标题
                desc: '{$item.intro}', // 分享描述
                link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: "{$item.pic_url}", // 分享图标
                type: '', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () {
// 用户点击了分享后执行的回调函数
                }
            });
        });

        wx.ready(function () {      //需在用户可能点击分享按钮前就先调用
            wx.onMenuShareTimeline({
                title: '{$item.title}', // 分享标题
                link: url, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                imgUrl: "{$item.pic_url}", // 分享图标
                success: function () {
                    // 用户点击了分享后执行的回调函数
                },
            })
        });
    }
function isWeiXin(){
    var ua = window.navigator.userAgent.toLowerCase();
    if(ua.match(/MicroMessenger/i) == 'micromessenger'){
        return true;
    }else{
        return false;
    }
}
function getWxAddress() {
    var is_address = $('#is_address').text();
    if (is_address == 'false'){
        return true
    }
    if (confirm('为了更好的给你提供服务,请允许我们获取您的地理位置')){
        wx.ready(function () {
            wx.checkJsApi({
                jsApiList: [
                    'getLocation'
                ],
                success: function (res) {
                    // alert(JSON.stringify(res));
                    // alert(JSON.stringify(res.checkResult.getLocation));
                    if (res.checkResult.getLocation == false) {
                        $.ajax({
                            url: "{:U('detail/saveUserLocation')}",
                            data: {
                                id: {$item.id},
                                is_allow: false,
								baidu_text: '用户微信版本太低不支持获取地理位置'
                            },
                            type: 'post',
                            dataType: "json",
                            timeout: 5000,
                            async: true,
                            success: function (data) {
                                console.log(data)
                                if (data.status == 'ok') {

                                } else {
                                    layer.msg(data.msg,{icon: 2,time:2000});
                                }
                            },
                        });
                        return;
                    }
                }
            });
            //通过微信进来获取当前用户位置
            var channel = $('#channel').text();
            if (channel == 'wx') {
                var latitude = ''; // 纬度，浮点数，范围为90 ~ -90
                var longitude = ''; // 经度，浮点数，范围为180 ~ -180。
                var speed = ''; // 速度，以米/每秒计
                var accuracy = ''; // 位置精度
                wx.getLocation({
                    type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
                    success: function (res) {
                        latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                        longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                        speed = res.speed; // 速度，以米/每秒计
                        accuracy = res.accuracy; // 位置精度
                        $.ajax({
                            url: "{:U('detail/saveUserLocation')}",
                            data: {
                                id: {$item.id},
                                is_allow: true,
                                latitude: latitude,
                                longitude: longitude,
                                speed: speed,
                                accuracy: accuracy
                            },
                            type: 'post',
                            dataType: "json",
                            timeout: 5000,
                            async: true,
                            success: function (data) {
                                console.log(data)
                                if (data.status == 'ok') {

                                } else {
                                    layer.msg(data.msg,{icon: 2,time:2000});
                                }
                            },

                        });
                    },
                    cancel: function (res) {
                        $.ajax({
                            url: "{:U('detail/saveUserLocation')}",
                            data: {
                                id: {$item.id},
                                is_allow: false
                            },
                            type: 'post',
                            dataType: "json",
                            timeout: 5000,
                            async: true,
                            success: function (data) {
                                console.log(data)
                                if (data.status == 'ok') {

                                } else {
                                    layer.msg(data.msg,{icon: 2,time:2000});
                                }
                            },
                        });
                    }
                });
            }
        })
    }else{
        $.ajax({
            url: "{:U('detail/saveUserLocation')}",
            data: {
                id: {$item.id},
                is_allow: false
            },
            type: 'post',
            dataType: "json",
            timeout: 5000,
            async: true,
            success: function (data) {
                console.log(data)
                if (data.status == 'ok') {

                } else {
                    layer.msg(data.msg,{icon: 2,time:2000});
                }
            },
        });
    }

}
</script>
	</body>
</html>
